package org.example.yongyou;

import java.util.ArrayList;

public class 销售订单列表查询建表工具 {

    public static void main(String[] args) {

        String s = "code\tstring    \t单据编号\n" +
                "vouchdate\tstring    \t单据日期\n" +
                "id\tlong    \t主体ID\n" +
                "parentOrderNo\tstring    \t父级订单号\n" +
                "salesOrgId\tstring    \t销售组织id\n" +
                "salesOrgId_name\tstring    \t销售组织名称\n" +
                "saleDepartmentId\tstring    \t销售部门id\n" +
                "transactionTypeId\tstring    \t交易类型id\n" +
                "transactionTypeId_name\tstring    \t交易类型名称\n" +
                "agentId\tlong    \t客户id\n" +
                "agentId_name\tstring    \t客户名称\n" +
                "receiveContacter\tstring    \t客户联系人\n" +
                "receiveContacterPhone\tstring    \t客户联系人电话\n" +
                "receievInvoiceMobile\tstring    \t收票手机号\n" +
                "receievInvoiceEmail\tstring    \t收票邮箱\n" +
                "purchaseNo\tstring    \t客户采购订单号\n" +
                "corpContact\tstring    \t销售业务员id\n" +
                "corpContactUserName\tstring    \t销售业务员\n" +
                "settlementOrgId_name\tstring    \t开票组织名称\n" +
                "corpContactUserErpCode\tstring    \t业务员erp编码\n" +
                "orderPrices.currency\tstring    \t币种id\n" +
                "orderPrices.currency_priceDigit\tlong    \t原币单价精度\n" +
                "orderPrices.currency_moneyDigit\tlong    \t原币金额精度\n" +
                "orderPrices.originalName\tstring    \t币种\n" +
                "orderPrices.natCurrency\tstring    \t本币pk\n" +
                "orderPrices.natCurrency_priceDigit\tlong    \t本币单价精度\n" +
                "orderPrices.natCurrency_moneyDigit\tlong    \t本币金额精度\n" +
                "orderPrices.domesticCode\tstring    \t本币简称\n" +
                "orderPrices.domesticName\tstring    \t本币\n" +
                "orderPrices.exchRate\tint    \t汇率\n" +
                "orderPrices.exchangeRateType_name\tstring    \t汇率类型名称\n" +
                "orderPrices.exchangeRateType\tstring    \t汇率类型Idid\n" +
                "orderPrices.ctTplId\tstring    \t合同模板id\n" +
                "orderPrices.ctTplCode\tstring    \t合同模板编码\n" +
                "orderPrices.ctTplName\tstring    \t合同模板\n" +
                "payMoney\tdouble    \t合计含税金额\n" +
                "orderPayMoney\tdouble    \t商品实付金额\n" +
                "realMoney\tdouble    \t应收金额\n" +
                "orderRealMoney\tdouble    \t商品应付金额\n" +
                "statusCode\tstring    \t订单当前状态码\n" +
                "nextStatus\tstring    \t订单状态, CONFIRMORDER:开立、DELIVERY_PART:部分发货、DELIVERY_TAKE_PART:部分发货待收货、DELIVERGOODS:待发货、TAKEDELIVERY:待收货、ENDORDER:已完成、OPPOSE:已取消、APPROVING:审批中、\n" +
                "currentStatus\tlong    \t当前状态位置\n" +
                "payStatusCode\tstring    \t付款状态, NOTPAYMENT:未付款、PARTPAYMENT:部分付款、CONFIRMPAYMENT:部分付款待确认、CONFIRMPAYMENT_ALL:付款待确认、FINISHPAYMENT:付款完成、\n" +
                "settlementOrgId\tstring    \t开票组织id\n" +
                "lockIn\tboolean    \t标记锁\n" +
                "confirmDate\tstring    \t订单确认时间\n" +
                "payDate\tstring    \t订单付款时间\n" +
                "orderPayType\tstring    \t支付方式\n" +
                "settlement\tstring    \t结算方式id\n" +
                "shippingChoiceId\tstring    \t发运方式id\n" +
                "sendDate\tstring    \t预计发货日期\n" +
                "hopeReceiveDate\tstring    \t期望收货日期\n" +
                "opposeMemo\tstring    \t驳回批注\n" +
                "haveDelivery\tboolean    \t是否存在发货单\n" +
                "occupyInventory\tstring    \t库存占用时机标识\n" +
                "separatePromotionType\tstring    \t拆单规则标识\n" +
                "reight\tdouble    \t运费\n" +
                "synSourceOrg\tstring    \t协同来源组织id\n" +
                "synSourceTenant\tstring    \t协同来源租户\n" +
                "synSourceOrg_name\tstring    \t协同来源组织名称\n" +
                "totalMoney\tdouble    \t总金额\n" +
                "tagName\tstring    \t采购组织弹框\n" +
                "rebateCashMoney\tdouble    \t抵现金额\n" +
                "particularlyMoney\tdouble    \t特殊优惠\n" +
                "promotionMoney\tdouble    \t促销\n" +
                "unConfirmPrice\tdouble    \t未审核的金额\n" +
                "confirmPrice\tdouble    \t已支付金额\n" +
                "bizId\tstring    \t商家id\n" +
                "bizName\tstring    \t商家名称\n" +
                "agentRelationId\tlong    \t客户交易关系id\n" +
                "points\tstring    \t积分\n" +
                "pubts\tstring    \t时间戳,格式为:yyyy-MM-dd HH:mm:ss\n" +
                "pubuts\tstring    \t时间戳\n" +
                "orderInvoice\tstring    \t发票信息\n" +
                "orderShippingAddress\tstring    \t收货地址信息\n" +
                "orderErp\tstring    \t订单erp\n" +
                "deliveryDate\tstring    \t交货日期\n" +
                "isWfControlled\tboolean    \t是否审批流控制\n" +
                "verifystate\tlong    \t审批状态\n" +
                "status\tlong    \t状态\n" +
                "isFinishDelivery\tboolean    \t订单是否发完货\n" +
                "productId_pbatchName\tlong    \t商品包装单位\n" +
                "idKey\tstring    \t行标识\n" +
                "productId\tlong    \t商品id\n" +
                "priceMark\tboolean    \t价格标识\n" +
                "isBatchManage\tboolean    \t是否批次管理\n" +
                "isExpiryDateManage\tboolean    \t是否有效期管理\n" +
                "expireDateNo\tstring    \t保质期\n" +
                "expireDateUnit\tstring    \t保质期单位\n" +
                "skuId\tlong    \t商品SKUid\n" +
                "erpCode\tstring    \tskuERP编码\n" +
                "orderProductType\tstring    \t商品售卖类型, SALE:销售品、GIFT:赠品、MARKUP:加价购、REBATE:返利商品、\n" +
                "productCode\tstring    \t商品编码\n" +
                "productName\tstring    \t商品名称\n" +
                "skuCode\tstring    \tSKU编码\n" +
                "specDescription\tstring    \t规格描述\n" +
                "projectId\tstring    \t项目id\n" +
                "unitExchangeType\tint    \t浮动（计价）\n" +
                "unitExchangeTypePrice\tint    \t浮动（销售）\n" +
                "productAuxUnitName\tstring    \t销售单位\n" +
                "invExchRate\tdouble    \t销售换算率\n" +
                "subQty\tdouble    \t销售数量\n" +
                "productUnitName\tstring    \t计价单位\n" +
                "invPriceExchRate\tdouble    \t计价换算率\n" +
                "priceQty\tdouble    \t计价数量\n" +
                "qtyName\tstring    \t主计量\n" +
                "qty\tdouble    \t数量\n" +
                "variantconfigctsId\tstring\t  小数位数:0,最大长度:20    选配结果清单id\n" +
                "orderDetailPrices.saleCost_orig_taxfree\tdouble    \t原币无税合计\n" +
                "orderDetailPrices.oriUnitPrice\tdouble    \t无税成交价\n" +
                "orderDetailPrices.oriMoney\tdouble    \t无税金额\n" +
                "orderDetailPrices.oriTax\tdouble    \t税额\n" +
                "orderDetailPrices.natSum\tdouble    \t本币含税金额\n" +
                "orderDetailPrices.natTaxUnitPrice\tdouble    \t本币含税单价\n" +
                "orderDetailPrices.natMoney\tdouble    \t本币无税金额\n" +
                "orderDetailPrices.natUnitPrice\tdouble    \t本币无税单价\n" +
                "orderDetailPrices.natTax\tdouble    \t本币税额\n" +
                "orderDetailPrices.orderDetailId\tlong    \t订单详情id\n" +
                "orderDetailPrices.salePrice_orig_taxfree\tdouble    \t无税单价\n" +
                "orderDetailPrices.rebateMoneyOrigTaxfree\tdouble    \t无税分摊返利\n" +
                "orderDetailPrices.particularlyMoneyOrigTaxfree\tdouble    \t无税特殊优惠\n" +
                "orderDetailPrices.promotionMoneyOrigTaxfree\tdouble    \t无税促销优惠\n" +
                "orderDetailPrices.pointsMoneyOrigTaxfree\tdouble    \t无税积分抵扣\n" +
                "orderDetailPrices.saleCost_domestic\tdouble    \t报价本币含税金额\n" +
                "orderDetailPrices.salePrice_domestic\tdouble    \t报价本币含税单价\n" +
                "orderDetailPrices.rebateMoneyDomestic\tdouble    \t本币分摊返利\n" +
                "orderDetailPrices.particularlyMoneyDomestic\tdouble    \t本币特殊优惠\n" +
                "orderDetailPrices.promotionMoneyDomestic\tdouble    \t本币促销优惠\n" +
                "orderDetailPrices.pointsMoneyDomestic\tdouble    \t本币积分抵扣\n" +
                "orderDetailPrices.saleCost_domestic_taxfree\tdouble    \t报价本币无税金额\n" +
                "orderDetailPrices.salePrice_domestic_taxfree\tdouble    \t报价本币无税单价\n" +
                "orderDetailPrices.rebateMoneyDomesticTaxfree\tdouble    \t本币无税分摊返利\n" +
                "orderDetailPrices.particularlyMoneyDomesticTaxfree\tdouble    \t本币无税特殊优惠\n" +
                "orderDetailPrices.promotionMoneyDomesticTaxfree\tdouble    \t本币无税促销优惠\n" +
                "orderDetailPrices.pointsMoneyDomesticTaxfree\tdouble    \t本币无税积分抵扣\n" +
                "orderDetailPrices.id\tlong    \t主体ID\n" +
                "orderDetailPrices.prepayInvRvnRecogBkgMeth\tstring    \t预收款开票应收入账方式 (1: 预收款开票-税额记应收 ; 2 : 预收款开票-全额记应收 )\n" +
                "orderDetailPrices.checkByRevenueManagement\tstring    \t收入管理核算\n" +
                "orderDetailPrices.revPerformObligation\tstring    \t已生成收入履约义务\n" +
                "orderDetailPrices.serviceStartDate\tstring    \t服务起始日期\n" +
                "orderDetailPrices.serviceEndDate\tstring    \t服务结束日期\n" +
                "orderDetailPrices.optionalQuotationId\tstring \t  报价配置清单ID\n" +
                "orderDetailPrices.optionalQuotationId_code\tstring    \t报价配置清单编码\n" +
                "orderDetailPrices.variantconfigctsCode\tstring    \t配置号\n" +
                "orderDetailPrices.variantconfigctsVersion\tstring    \t配置清单版本\n" +
                "stockName\tstring    \t发货仓库\n" +
                "stockOrgId_name\tstring    \t库存组织\n" +
                "consignTime\tstring    \t计划发货日期\n" +
                "projectId_name\tstring    \t项目名称\n" +
                "projectId_code\tstring    \t项目编码\n" +
                "noTaxSalePrice\tdouble    \t无税报价\n" +
                "salePrice\tdouble    \t含税报价\n" +
                "taxId\tstring    \t数目税率id\n" +
                "costCurrencyName\tstring    \t成本币种\n" +
                "costAmt\tBigDecimal    \t成本金额\n" +
                "costPrice\tBigDecimal    \t成本价\n" +
                "noTaxSaleCost\tdouble    \t报价无税金额\n" +
                "saleCost\tdouble    \t报价含税金额\n" +
                "stockId\tstring    \t仓库ID\n" +
                "oriTaxUnitPrice\tdouble    \t含税成交价\n" +
                "lineno\tint    \t行号\n" +
                "orderDetails_stockOrgId\tstring    \t库存组织id\n" +
                "oriSum\tdouble    \t含税金额\n" +
                "transactionTypeId\tstring    \t交易类型id\n" +
                "taxRate\tdouble    \t税率\n" +
                "taxItems\tstring    \t税目\n" +
                "taxCode\tstring    \t税目税率编码\n" +
                "rebateMoney\tdouble    \t返利分摊金额\n" +
                "pointsMoney\tdouble    \t积分\n" +
                "shoppingCartId\tstring    \t购物车id\n" +
                "groupId\tlong    \t分组Id\n" +
                "rebateReturnProductId\tstring    \t返货单商品id\n" +
                "mutualActivities\tstring    \t活动的对象,用于校验互斥活动\n" +
                "activities\tstring    \t包含的类型,用于校验互斥\n" +
                "salesOrgId\tstring    \t销售组织id\n" +
                "sendPayMoney\tdouble    \t累计已发货含税金额\n" +
                "saleDepartmentId\tstring    \t销售部门id\n" +
                "invoiceQty\tdouble    \t累计开票数量\n" +
                "settlementOrgId\tstring    \t财务组织id\n" +
                "invoiceOriSum\tdouble    \t累计开票含税金额\n" +
                "bizProductId\tlong    \t商家商品id\n" +
                "takeQuantity\tdouble    \t已审核收数量\n" +
                "bizSkuId\tstring    \t商家skuid\n" +
                "takeSalePayMoney\tdouble    \t已审核收金额\n" +
                "orderDetailPrice\tdouble    \t订单金额\n" +
                "sendQty\tdouble    \t累计已发货数量\n" +
                "closedSumMoney\tdouble    \t关闭总金额\n" +
                "closedRowCount\tdouble    \t行关闭数量\n" +
                "iDeleted\tboolean    \t是否删除\n" +
                "iOrgId\tstring    \t组织ID\n" +
                "memo\tstring    \t备注\n" +
                "createDate\tstring    \t创建日期\n" +
                "creatorId\tlong    \t创建人\n" +
                "auditorId\tstring    \t审核人ID\n" +
                "auditDate\tstring    \t审批日期\n" +
                "closerId\tstring    \t关闭人ID\n" +
                "closeDate\tstring    \t关闭日期\n" +
                "modifierId\tstring    \t修改人id\n" +
                "modifyDate\tstring    \t修改日期\n" +
                "cCreator\tstring    \t创建人\n" +
                "iProductAuxUnitId\tlong    \t销售单位id\n" +
                "iProductUnitId\tlong    \t计价单位id\n" +
                "masterUnitId\tlong    \t主计量单位id\n" +
                "purUOM_Precision\tlong    \t销售单位精度\n" +
                "priceUOM_Precision\tlong    \t计价单位精度\n" +
                "unit_Precision\tlong    \t主计量单位精度\n" +
                "cBizName\tstring    \t供应商名称\n" +
                "orderDetailId\tlong    \t主体ID\n" +
                "orderId\tlong    \t订单ID\n" +
                "creator\tstring    \t创建人\n" +
                "createTime\tstring    \t创建时间\n" +
                "auditor\tstring   \t  审批人\n" +
                "auditTime\tstring  \t   审批时间\n" +
                "closeTime\tstring   \t  关闭时间\n" +
                "closer\tstring   \t  关闭人\n" +
                "modifier\tstring  \t   修改人\n" +
                "modifyTime\tstring  \t   修改时间\n" +
                "bmake_st_salesout\tstring \t    流程入库\n" +
                "bmake_voucher_delivery\tstring  \t   流程发货\n" +
                "bizFlow\tlong   \t  流程ID\n" +
                "bmake_voucher_saleinvoice\tstring   \t  流程开票\n" +
                "isFlowCoreBill\tboolean  \t   是否流程核心单据\n" +
                "bizFlow_version\tstring  \t   版本信息\n" +
                "batchNo\tstring   \t  批次号\n" +
                "productDate\tstring  \t   生产日期\n" +
                "invalidDate\tstring  \t   有效期至\n" +
                "isAdvRecInv\tboolean   \t  预收款开票\n" +
                "advRecInvMoney\tdouble  \t   累计预收款开票金额\n" +
                "advRecInvQty\tdouble  \t   累计预收款开票数量\n" +
                "natAdvRecInvMoney\tdouble  \t   累计本币预收款开票金额\n" +
                "advRecInvTaxMoney\tdouble  \t   累计预收款开票税额\n" +
                "natAdvRecInvTaxMoney\tdouble \t    累计本币预收款开票税额\n" +
                "offsetAdvRecInvMoney\tdouble  \t   累计冲抵预收款开票金额\n" +
                "offsetAdvRecInvQty\tdouble  \t   累计冲抵预收款开票数量\n" +
                "offsetNatAdvRecInvMoney\tdouble  \t   累计冲抵本币预收款开票金额\n" +
                "offsetAdvRecInvTaxMoney\tdouble  \t   累计冲抵预收款开票税额\n" +
                "offsetNatAdvRecInvTaxMoney\tdouble \t    累计冲抵本币预收款开票税额\n" +
                "tradeRouteID\tstring   \t  贸易路径ID\n" +
                "tradeRouteID_code\tstring  \t   贸易路径编码\n" +
                "tradeRouteID_name\tstring \t    贸易路径\n" +
                "isEndTrade\tint  \t   是否末级站点\n" +
                "tradeRouteLineno\tstring  \t   站点\n" +
                "collaborationPocode\tstring \t    协同来源单据号\n" +
                "collaborationPodetailid\tstring   \t  协同来源单据子表id\n" +
                "collaborationPoid\tstring  \t   协同来源单据主表id\n" +
                "collaborationPorowno\tstring \t    协同来源单据行号\n" +
                "collaborationSource\tstring   \t  协同来源单据类型\n" +
                "entireDeliveryStatus\tstring   \t整单发货状态\n" +
                "entireIssueStatus\t   string\t整单出库状态\n" +
                "entireInvoiceStatus\t   string\t整单发票状态\n" +
                "entireSignConfirmStatus\t   string\t整单签收状态\n" +
                "deliveryStatus\tstring   \t发货状态\n" +
                "issueStatus\tstring   \t出库状态\n" +
                "invoiceStatus\tstring   \t发票状态\n" +
                "signConfirmStatus\tstring   \t签收状态";

        ArrayList<Field> fields = new ArrayList<>();
        //按照换行符分割
        String[] split = s.split("\n");
        //split 按照\t 分割
        for (String s1 : split) {
            String[] split1 = s1.split("\t");

            //如果split1[0].trim() 里面包含 .   那么将.替换成_
            if (split1[0].trim().contains(".")) {
                split1[0] = split1[0].trim().replace(".", "_");
            }


            fields.add(new Field(split1[0].trim(), split1[1].trim(), split1[2].trim()));
        }

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("CREATE TABLE yong_bip_voucherorder_list (\n" +
                        "bai_shu_id int primary key auto_increment comment '百数云id',\n")
                .append("bai_shu_create_time datetime default CURRENT_TIMESTAMP comment '百数云创建时间',\n");
        for (Field field : fields) {
            if (field.type.equals("string") || field.type.equals("BigDecimal") || field.type.equals("boolean")) {
                stringBuffer.append(field.name).append(" varchar(255) comment '").append(field.comment).append("',\n");
            } else if (field.type.equals("long")) {
                stringBuffer.append(field.name).append(" bigint comment '").append(field.comment).append("',\n");
            } else if (field.type.equals("int")) {
                stringBuffer.append(field.name).append(" int comment '").append(field.comment).append("',\n");
            } else if (field.type.equals("double")) {
                stringBuffer.append(field.name).append(" double comment '").append(field.comment).append("',\n");
            } else {
                System.out.println("未知类型：" + field.type);
            }
        }
        //删除最后一个逗号
        stringBuffer.deleteCharAt(stringBuffer.length() - 2);
        stringBuffer.append(") COMMENT='用友BIP销售订单列表查询';");
        System.out.println("stringBuffer = " + stringBuffer);


    }

}

class Field {
    String name;
    String type;
    String comment;

    public Field(String name, String type, String comment) {
        this.name = name;
        this.type = type;
        this.comment = comment;
    }

}
